/*****************************************************************


			G L O B A L   V A R S


*****************************************************************/
ConVar g_CvarShowConnectionMsg = null;
ConVar g_CvarShowDisonnectionMsg = null;


/*****************************************************************


			F O R W A R D   P U B L I C S


*****************************************************************/
void SetupSuppress()
{
	g_CvarShowConnectionMsg = CreateConVar("sm_ca_showstandard", "0", "shows standard player connected message");
	g_CvarShowDisonnectionMsg = CreateConVar("sm_ca_showstandarddisc", "0", "shows standard player discconnected message");
	
	//player_connect_client replaced player_connect but the old event is still required for some older games. 
	//lets try the new event first then fallback if it dont worky
	if( HookEventEx("player_connect_client", event_PlayerConnectClient, EventHookMode_Pre) == false )
	{
		HookEventEx("player_connect", event_PlayerConnect, EventHookMode_Pre);
	}
}


/****************************************************************


			C A L L B A C K   F U N C T I O N S


****************************************************************/
//For the newer event player_connect_client
public Action event_PlayerConnectClient(Event event, char[] name, bool dontBroadcast)
{
    if (!g_CvarShowConnectionMsg.BoolValue)
    {
        event.BroadcastDisabled = true;
    }

    return Plugin_Continue;
}

//For the older event player_connect
public Action event_PlayerConnect(Event event, char[] name, bool dontBroadcast)
{
    if (!g_CvarShowConnectionMsg.BoolValue)
    {
        event.BroadcastDisabled = true;
    }

    return Plugin_Continue;
}


void event_PlayerDisconnect_Suppress(Event event)
{
    if (!g_CvarShowDisonnectionMsg.BoolValue)
    {
        event.BroadcastDisabled = true; // 聊天框: 玩家離開遊戲
    }
}